package patrol.mobile.com.mobilepatrol.activity.security.emergency;

import android.support.v7.widget.RecyclerView;

import com.dl7.recycler.helper.RecyclerViewHelper;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.ConsTitles;
import patrol.mobile.com.mobilepatrol.activity.security.StickyEventBody;
import patrol.mobile.com.mobilepatrol.activity.security.adapter.EmergencyPeopleInfoLendAdapter;
import patrol.mobile.com.mobilepatrol.bean.PeopleInfoBean;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;

public class EmergencyPeopleInfoLendFragment extends BaseFragment{

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    private List<PeopleInfoBean.AnbkRentedHouseListBean> anbkRentedHouseListBean = new ArrayList<>();
    private EmergencyPeopleInfoLendAdapter emergencyPeopleInfoLendAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_family;
    }

    @Override
    protected void initData() {
        emergencyPeopleInfoLendAdapter = new EmergencyPeopleInfoLendAdapter(getContext());
        EmergencyPeopleInfoActivity activity = (EmergencyPeopleInfoActivity) getActivity();
        activity.setMainTitle(ConsTitles.EMERGENCY_PEOPLE_INFO);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initView() {
        super.initView();
        EventBus.getDefault().register(this);
    }


    @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
    public void ReceviceMessage(StickyEventBody stickyEventBody){
        PeopleInfoBean protectListBean =stickyEventBody.protectListBean;
        anbkRentedHouseListBean = protectListBean.getAnbkRentedHouseList();
        RecyclerViewHelper.initRecyclerViewV(getContext(),
                recyclerView, emergencyPeopleInfoLendAdapter);
        emergencyPeopleInfoLendAdapter.updateItems(anbkRentedHouseListBean);
    }



    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().removeAllStickyEvents();
        EventBus.getDefault().unregister(this);
    }
}
